/* @(#)
 *
 * Project:NEBMis
 *
 * Modify Information:
 * =============================================================================
 *   Author         Date           Description
 *   ------------ ---------- ---------------------------------------------------
 *   PanShuang      2010-3-10       first release
 *
 *
 * Copyright Notice:
 * =============================================================================
 *       Copyright 2010 Huateng Software, Inc. All rights reserved.
 *
 *       This software is the confidential and proprietary information of
 *       Shanghai HUATENG Software Co., Ltd. ("Confidential Information").
 *       You shall not disclose such Confidential Information and shall use it
 *       only in accordance with the terms of the license agreement you entered
 *       into with Huateng.
 *
 * Warning:
 * =============================================================================
 *
 */
package cn.vcjf.washcar.common.util;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.ResourceBundle;

/**
 * Title:系统参数
 * 
 * Description:
 * 
 * Copyright: Copyright (c) 2010-3-10
 * 
 * Company: Shanghai Huateng Software Systems Co., Ltd.
 * 
 * @author PanShuang
 * 
 * @version 1.0
 */
@Component
public class SysParamUtil {

	private static String SYSPARAM_FILE = "sys";
	private static String CONFIG_FILE = "config";

	private static ResourceBundle BUNDLE = ResourceBundle.getBundle(SYSPARAM_FILE);

	private static ResourceBundle CONFIG = ResourceBundle.getBundle(CONFIG_FILE);

	public static String sys_mode=getConfigParam("sys_mode");

	/**
	 * 获得系统参数
	 * @param key
	 * @return
	 */
	public static String getParam(String key) {
		/**
		 * 自动加载配置文件和根据项目名称取各个项目的参数
		 */
		String bundleString = "";
		if (StringUtils.isBlank(key)) {
			return bundleString;
		}
		try {
			bundleString = BUNDLE.getString(key);
		}catch (Exception e){
			System.out.println(e.getMessage());
		}
		return bundleString;
	}
	/**
	 * 获得配置参数
	 * @param key
	 * @return
	 */
	public static String getConfigParam(String key) {
		/**
		 * 自动加载配置文件和根据项目名称取各个项目的参数
		 */
		String bundleString = "";
		if (StringUtils.isBlank(key)) {
			return bundleString;
		}
		try {
			bundleString = CONFIG.getString(key);
		}catch (Exception e){
			System.out.println(e.getMessage());
		}
		return bundleString;
	}

	/**
	 * 是否是测试,开发环境
	 * @return
	 */
	public static boolean isTestModel(){
		return "dev".equals(sys_mode);
	}
}
